var bindData = {};
var bindTable;

// ===================================================

$(".searchBtn2").click(function() {
	bindData.con = $("#search2").val();
	var val = $("#clickId").val();
	if (val == '') {
		val = '0';
	}
	bindData.key = val;
	var ownAttr = $("#ownAttr").val();
	if (ownAttr == undefined || '' == ownAttr) {
		ownAttr = 'root';
	}
	bindData.attr = ownAttr;
	bindTable.draw();
});
$(".resetBtn2").click(function() {
	$("#search2").val('');
	var val = $("#clickId").val();
	if (val == '') {
		val = '0';
	}
	bindData.key = val;
	bindData.con = '';
	var ownAttr = $("#ownAttr").val();
	if (ownAttr == undefined || '' == ownAttr) {
		ownAttr = 'root';
	}
	bindData.attr = ownAttr;
	bindTable.draw();
});
// =========================================================
function showBindPart(id, ar) {
	// 搜索框
	var con = $("#search2").val();
	bindData.con = con;
	bindData.key = id;
	bindData.attr = ar;
	bindTable = $('#bindPart')
			.DataTable(
					{
						"serverSide" : true,
						"ordering" : false,
						"ajax" : {
							"dataType" : "json",
							"type" : "post",
							"cache" : false,
							"url" : window.rootPath + '/ui/dgp/showBindPart',
							"data" : function(d) {
								return $.extend({}, d, bindData);
							}
						},
						columns : [ {
							data : null,
							defaultContent : ""
						}, {
							data : "partName",
						}, {
							data : 'partIdentify',
						}, {
							data : 'gridAreaInfo.gridName'
						}, {
							data : 'part.partType.title'
						} ],
						"drawCallback" : function(oSettings) {
							var k = 0;
							var total = oSettings.aiDisplay.length
									+ oSettings._iDisplayStart;
							for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
								$(
										'td:eq(0)',
										oSettings.aoData[oSettings.aiDisplay[k]].nTr)
										.text(i + 1);
								k++;
							}
							bindTable.off('click', 'tr');

						}
					});
	bindTable.draw();
}